package com.hao.demo1;

public class rtraceTest implements Runnable {
    // 总距离
    private int k = 10;
    @Override
    public void run() {
        while (true){
            if (k<0){

                System.out.println(Thread.currentThread().getName()+"赢得了比赛！！！");
                break;
            }

            System.out.println("比赛进行中...,剩余"+k);
            k--;
        }
    }

    public static void main(String[] args) throws InterruptedException {
        rtraceTest race = new rtraceTest();
        new Thread(race,"乌龟").start();
        new Thread(race, "兔子").start();
        if (Thread.currentThread().getName().equals("兔子")){
            Thread.sleep(2000);
        }
    }
}
